package core.utils;

import core.Model;

import java.util.TreeSet;




/**
 * Encapsulates a variable with its datapoints.
 */
public class VariableDataSet implements Comparable<VariableDataSet>{
	private Variable var;
	private int id;
	private TreeSet<LogData> dataPoints;

	@SuppressWarnings("unused")
	private VariableDataSet() {
	}

	public VariableDataSet(Variable var, TreeSet<LogData> dataPoints) {
		this.var = var;
		id = Model.getVariableIds().get(var);
		this.dataPoints = dataPoints;
	}

	public TreeSet<LogData> getData() {
		return dataPoints;
	}

	public Variable getVariable() {
		return var;
	}

	@Override
	public boolean equals(Object o) {
		if (o instanceof VariableDataSet) {
			VariableDataSet dataset = (VariableDataSet) o;
			return (dataset.var.equals(var) && dataset.dataPoints.equals(dataPoints));
		} else {
			return false;
		}
	}

    @Override
    public int hashCode() {
        return dataPoints.hashCode() ^ var.hashCode();
    }

	@Override
	public int compareTo(VariableDataSet arg0) {
		return (this.id - arg0.id);
	}
}
